<?php

namespace App\Service\Message\v1_1_2;

use App\Model\UserAutoMsg;
use App\Service\BaseService;

/**
 * 自动聊天消息设置信息
 */
class AutoMsgInfoService extends BaseService
{
    public function handle()
    {
        $userId = $this->getUserId();
        $msgs = UserAutoMsg::getUserMsgs($userId);
        $ret = [
            //自动招呼设置
            'intro_title' => '自动打招呼有什么用？',
            'intro_desc' => "设置自动打招呼后，每次用户上线你只要轻轻点击《一键搭讪》，系统将随机发送一条你已填写的招呼内容给他，快速与他建立聊天。\n\n注：新设置的打招呼消息需审核通过才生效～",
        ];
        $msgTypes = array_keys(UserAutoMsg::TYPE_HOST);
        foreach ($msgTypes as $msgType) {
            $ret['msg_' . $msgType] = [
                'msg_num' => isset($msgs[$msgType]) ? count($msgs[$msgType]) : 0,
                'msg_arr' => $msgs[$msgType] ?? null,
            ];
        }
        log_info(__CLASS__ . "=={$userId}==" . json_encode($ret));
        return $ret;
    }
}
